﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZyGames.DZPocker.Bll.Logic;
using ZyGames.Framework.Game.Contract;
using ZyGames.Framework.Game.Runtime;
using ZyGames.Framework.Game.Service;
using ZyGames.Framework.RPC.Sockets;
using ZyGames.Framework.Script;

namespace Game.Script
{
	public class MainClass : GameSocketHost, IMainScript
	{
		public MainClass()
		{

		}

		protected override void OnStartAffer()
		{
		}

		protected override void OnServiceStop()
		{
			GameEnvironment.Stop();
		}

		protected override void OnConnectCompleted(object sender, ConnectionEventArgs e)
		{
			Console.WriteLine("客户端IP:[{0}]已与服务器连接成功", e.Socket.RemoteEndPoint);
			base.OnConnectCompleted(sender, e);
		}

		protected override void OnDisconnected(GameSession session)
		{
			Console.WriteLine("客户端UserId:[{0}]已与服务器断开", session.RemoteAddress);
			//GameTable.Current.OnDisconnectEvent(session.UserId);
			base.OnDisconnected(session);
		}

		protected override void OnHeartbeat(GameSession session)
		{
			Console.WriteLine("{0}>>Hearbeat package: {1} userid {2} session count {3}", DateTime.Now.ToString("HH:mm:ss"), session.RemoteAddress, session.UserId, GameSession.Count);
			base.OnHeartbeat(session);
		}

		protected override void OnRequested(ActionGetter actionGetter, BaseGameResponse response)
		{
			Console.WriteLine("Client {0} request action {1}", actionGetter.GetSessionId(), actionGetter.GetActionId());
		}
	}
}
